package com.client.controller;

import com.client.pojo.AdminNotifications;
import com.client.service.AdminNotificationsService;
import com.client.utils.ResponseMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 管理员通知表 前端控制器
 * </p>
 *
 * @author ckick
 * @since 2025-09-20 08:28:53
 */
@RestController
@RequestMapping("/adminNotifications")
public class AdminNotificationsController {
    @Autowired
     private AdminNotificationsService adminNotificationsService;

    /**
     * 通过当前的用户ID获取所有的管理员的通知
     * @param receiverId 当前用户ID
     * @return 管理员通知消息列表
     */
    @GetMapping("getAdminNotifications/{receiverId}")
    public ResponseMsg getAdminNotifications(@PathVariable Integer receiverId) {
        List<AdminNotifications> adminNotifications =
                adminNotificationsService.getByIds(receiverId);
        if (adminNotifications == null) {
            return ResponseMsg.getInstance(ResponseMsg.ERROR,"暂无管理员通知的消息~");
        }
        return ResponseMsg.getInstance(ResponseMsg.SUCCESS,"查询完成!",adminNotifications);
    }
}
